<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/common.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-taxDeclaration-edit">
			<input id="declarationId" name="declarationId" value="${taxDeclaration.declarationId}" type="hidden">
			<input id="taskId" name="taskId" value="${taskId}" type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label">纳税人：</label>
				<div class="col-sm-8">
					<input id="owner" name="owner" value="${taxDeclaration.owner}" class="form-control" type="text" readonly="readonly">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">所属公司：</label>
				<div class="col-sm-8">
					<input id="company" name="company" value="${taxDeclaration.company}" class="form-control" type="text" readonly="readonly">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">税种：</label>
				<div class="col-sm-8">
					<input id="declarationTaxType" name="declarationTaxType" value="${taxDeclaration.declarationTaxType}" type="text" class="form-control"
						disabled="disabled">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">税目：</label>
				<div class="col-sm-8">
					<input id="declarationTaxModel" name="declarationTaxModel" value="${taxDeclaration.declarationTaxModel}" type="text" class="form-control"
						disabled="disabled">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">计税依据：</label>
				<div class="col-sm-8">
					<input id="declarationTaxBasis" name="declarationTaxBasis" value="${taxDeclaration.declarationTaxBasis}" class="form-control" type="text"
						disabled="disabled">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">应纳税项目：</label>
				<div class="col-sm-8">
					<input id="declarationTaxProject" name="declarationTaxProject" value="${taxDeclaration.declarationTaxProject}" class="form-control"
						disabled="disabled" type="text">
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-3 control-label">扣除项目及标准：</label>
				<div class="col-sm-8">
					<input id="declarationTaxCondition" name="declarationTaxCondition" value="${taxDeclaration.declarationTaxCondition}" class="form-control"
						type="text" disabled="disabled">

				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">适用税率（%）：</label>
				<div class="col-sm-8">
					<input id="declarationTaxRate" name="declarationTaxRate" value="${taxDeclaration.declarationTaxRate}" class="form-control" type="text"
						disabled="disabled">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">应纳税额：</label>
				<div class="col-sm-8">
					<input id="declarationTaxMoney" name="declarationTaxMoney" value="${taxDeclaration.declarationTaxMoney}" class="form-control" type="text"
						disabled="disabled">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">代收代缴税额：</label>
				<div class="col-sm-8">
					<input id="declarationReplaceMoney" name="declarationReplaceMoney" value="${taxDeclaration.declarationReplaceMoney}" class="form-control"
						type="text" disabled="disabled">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">税款所属期限：</label>
				<div class="col-sm-8">
					<input id="declarationTaxTime" name="declarationTaxTime"
						value='<fmt:formatDate pattern="yyyy-MM-dd"  value="${taxDeclaration.declarationTaxTime}" />' class="form-control" type="text"
						disabled="disabled">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">&nbsp;</label>
				<div class="col-sm-8">
					<select id="flag" name="flag" class="form-control">
						<option value="true">通过</option>
						<option value="false">不通过</option>
					</select>
				</div>
			</div>

			<c:if test="${ not empty taskId}">
				<div class="form-group">
					<label class="col-sm-3 control-label">&nbsp;</label>
					<div class="col-sm-8">
						<a class="btn btn-primary btn-del" onclick="submitHandler()">
							<i class="fa fa-play"></i>
							提交审核
						</a>
					</div>
				</div>
			</c:if>
		</form>
	</div>
	<script src="${ctx}/static/js/tax.json"></script>
	<script type="text/javascript">
		var prefix = "${ctx}/system/declaration";
		function submitHandler() {
			if ($.validate.form()) {
				$.operate.save(prefix + "/complete", $('#form-taxDeclaration-edit').serialize(), function(data) {
					if (data.code == 0) {
						alert(data.msg);
						window.location.href = '${ctx}/toDoTask/list/taxDeclaration';
					}
				});
			}
		}
	
	
		//获得省级下拉框对象
		var province = $("#declarationTaxType");
		var option = "<option value=''>--请选择--</option>";
		//遍历省市数据,并把里面省的数据追加到option选项中
		for (var i = 0; i < china.length; i++) {
			option += "<option value='" + china[i].p_id + "'  ";
			if ('${cartype.cartypeBrand}' == china[i].p_id) {
				option += " selected ";
			}
			option += ">" + china[i].p_name + "</option>";
		}
		province.append(option);
		if ('${taxDeclaration.declarationId}' != "") {
			changeCar('${taxDeclaration.declarationId}');
		}
	
	
		//省级下拉框发生改变事件
		$("#declarationTaxType").change(function() {
			//获取当前点击对象的值
			var proid = $(this).val();
			changeCar(proid);
			changeCondition(proid);
			var str = "";
			if (proid == "个人所得税") {
				$("#declarationTaxBasis").val("纳税人取得的应纳税所得额");
			} else if (proid == "企业所得税") {
				$("#declarationTaxBasis").val("按应纳税所得额（纳税调整后的利润）");
			}
		});
	
	
		function changeCondition(proid) {
			var content;
			//遍历省市数据,把省级下点击的那一个选项的值和省市数据中的
			//省级数据对比,如果相等,取出当前的市的数据
			for (var i = 0; i < china.length; i++) {
				if (proid == china[i].p_id) {
					content = china[i].content;
				}
			}
			//获得市级下拉框对象
			var city = $("#declarationTaxCondition");
			//每次点击省级后,市级初始化,避免高级重复追加 
			var option = "<option value=''>--请选择--</option>";
			//遍历市级数据,并取出市级数据,追加到市级对象中
			for (var i = 0; i < content.length; i++) {
				option += "<option value='" + content[i].c_id + "'  ";
				if ('${taxDeclaration.declarationId}' == content[i].c_id) {
					option += " selected ";
				}
				option += " num='" + content[i].c_num + "'";
				option += ">" + content[i].c_name + "</option>";
			}
			city.html(option);
		}
	
	
		function changeCar(proid) {
			var cities;
			//遍历省市数据,把省级下点击的那一个选项的值和省市数据中的
			//省级数据对比,如果相等,取出当前的市的数据
			for (var i = 0; i < china.length; i++) {
				if (proid == china[i].p_id) {
					cities = china[i].cities;
				}
			}
			//获得市级下拉框对象
			var city = $("#declarationTaxModel");
			//每次点击省级后,市级初始化,避免高级重复追加 
			var option = "<option value=''>--请选择--</option>";
			//遍历市级数据,并取出市级数据,追加到市级对象中
			for (var i = 0; i < cities.length; i++) {
				option += "<option value='" + cities[i].c_id + "'  ";
				if ('${taxDeclaration.declarationTaxModel}' == cities[i].c_id) {
					option += " selected ";
				}
				option += ">" + cities[i].c_name + "</option>";
			}
			city.html(option);
		}
	</script>
</body>
</html>
